<template>
    会员编号:
    <input type="text" v-model="biaohao">
    会员名称:
    <input type="text" v-model="Name">
    会员级别:
    <select v-model="Jibie">
                    <option :value="0">请选择</option>
                    <option  v-for="init in xiala" :value="init.R_Id">{{ init.R_Name }}</option>
                </select>
                <input type="button" value="查询"  @click="Show">
    <table border="1">
        <thead>
            <tr>
            <td>会员编号</td>
            <td>会员名称</td>
            <td>性别</td>
            <td>手机号码</td>
            <td>会员级别</td>
            <td>积分</td>
            <td>余额</td>
            <td>注册时间</td>
            <td>操作</td>
        </tr>
        </thead>
        <tbody>
            <tr v-for="init in showinfo">
            <td>{{ init.Bh }}</td>
            <td>{{  init.Name}}</td>
            <td>{{init.Sex}}</td>
            <td>{{ init.Phone.substring(0,3)+"****"+init.Phone.substring(7,12)}}</td>
            <td>{{ init.R_Name }}</td>
            <td>{{ init.Jifen }}</td>
            <td>¥{{ init.Maney.toFixed(2) }}</td>
            <td>{{ init.Date }}</td>
            <td>
                <input type="button" value="修改" @click="xiugai(init.Id)">
                <input type="button" value="删除" @click="shanchu(init.Id)">
             </td>
            </tr>
        </tbody>
       
    </table>
</template>

<script setup lang="ts">
import {onMounted,ref} from 'vue'
import axios from 'axios'
import { useRouter,useRoute } from 'vue-router';

const biaohao=ref("")
const Name=ref("")
const Jibie=ref(0)
const userou=useRoute();
const userour=useRouter();
onMounted(()=>{
    Show();    jibie()
})
const xiala=ref([{
    "R_Id": 0,
    "R_Name": ""
}])


const jibie=()=>{

    axios.get("https://localhost:7122/api/Member/GetRank")
    .then(res=>{
        xiala.value=res.data
    })
}

const showinfo=ref([{
    "R_Id": 2,
    "Maney": 111,
    "Phone": "111",
    "Jifen": 111,
    "Name": "111",
    "Date": "2024-11-18T21:03:07.537556",
    "Sex": true,
    "Bh": "20241118466238",
    "Id": "aac9488d-a195-4925-817f-311d04211be6",
    "R_Name": "黄金"
}])
const Show=()=>{
    axios.get("https://localhost:7122/api/Member/Showmemberinfos",{
        params:{
            bh:biaohao.value,
            name:Name.value,
            dj:Jibie.value

        }
    })
    .then(res=>{
      
           showinfo.value=res.data; 

     
    })
}
const xiugai=(id:string)=>{
    userour.push({
        name:"UpdaMemberinfo",
        params:{
            id:id
        }
    })
}
const shanchu=(Id:string)=>{
    axios.delete("https://localhost:7122/api/Member/DelMember",{
        params:{
            id:Id
        }
    }).then(res=>{
if(res.data>0){
    alert("删除成功");
    Show();
}else{
    alert("删除失败")
}
    })
}
</script>

<style scoped>

</style>